 // 主页
app.controller('homeCtrl',['$scope', '$http', '$stateParams', function ($scope,$http,$stateParams) {
    $scope.name = $stateParams.name;
    //请求数据
    $http.get($config.host+'?m=Evaluate&a=homeRender&flag='+$scope.name)
        .success(function (json) {
            console.log(json);
            if(json.errcode==0){
                $scope.jsons = json.data;
            }
        })
}]);

/*// 行业-排行榜
app.controller('traderankCtrl',['$scope','$http', function ($scope,$http) {
    //请求数据
    $http.get($config.host+'?m=Policy&a=platformIndustry')
        .success(function (json) {
            console.log(json);
            if(json.errcode==0){
                $scope.jsons = json.data;
                $scope.total = json.totalPlatform;
            }
        })
}]);

//红黑榜-总榜
app.controller('listsallCtrl',['$scope','$http', function ($scope,$http) {
    //请求数据
    $http.get($config.host+'?m=Policy&a=statistics')
        .success(function (json) {
            console.log(json);
            if(json.errcode==0){
                $scope.jsons = json.data;
            }
        })
}]);

//红黑榜-行业
app.controller('liststradeCtrl',['$scope','$http', '$stateParams', function ($scope,$http,$stateParams) {
    $scope.name = $stateParams.name;
    var postData = $config.urlCode({
        platformIndustry : $scope.name
    });
    //请求数据
    $http.post($config.host+'?m=Policy&a=industryStatistics',postData)
        .success(function (json) {
            console.log(json);
            if(json.errcode==0){
                $scope.jsons = json.data;
            }
        })
}]);*/

// 行业总榜
app.controller('tradeallCtrl',['$scope','$http', '$stateParams', function ($scope,$http,$stateParams) {
    $scope.name = $stateParams.name;
    $scope.page = 1;
    var size = 50;

    //请求数据
    var isLock = true;
    $scope.getLists = function () {
        if(!$scope.page||!isLock) return;
        isLock = false;
        var postData = $config.urlCode({
            evaluate_flag : $scope.name,
            page : $scope.page,
            size : size,
            type : 'APP'
        });
        $http.post($config.host+'?m=Evaluate&a=platformList',postData)
            .success(function (json) {
                console.log(json)
                if(json.errcode==0){
                    if($scope.page==1){
                        $scope.lists = json.data;

                    }else{
                        $scope.lists = $scope.lists.concat(json.data[0].data);
                    }
                    if(json.currentPage == json.totalPage){
                        $scope.page = false;
                    }else{
                        $scope.page ++;
                    }
                }
                isLock = true;
            })
    }

    $scope.getLists();
}]);

 // 搜索结果页
 /*app.controller('resultCtrl',['$scope','$http', '$stateParams', '$location', function ($scope,$http,$stateParams,$location) {
     var searchs = $scope.searchs = $location.search(), postData = {size:50}, postUrl;

     if(searchs.name=='filter'){
         postUrl = '?m=Policy&a=multiSearch';
         if(searchs.min && searchs.max){
             postData.scoreRange = searchs.min+','+searchs.max
         }
         if(searchs.type){
             postData.platformType = searchs.type;
         }
         if(searchs.industry){
             postData.platformIndustry = searchs.industry;
         }
     }else if(searchs.name=='sou'){
         postUrl = '?m=Policy&a=platformSearchName';
         postData.platformName = searchs.cont;
     }else{
         return;
     }

     // 初始化分页参数
     $scope.page = 1;

     //请求数据
     var isLock = true;
     $scope.postLists = function () {
         if(!$scope.page||!isLock) return;
         isLock = false;
         postData.page = $scope.page;
         $http.post($config.host+postUrl,$config.urlCode(postData))
             .success(function (json) {
                 console.log(json);
                 if(json.errcode==0){
                     $scope.content = 'yes';
                     if($scope.page==1){
                         $scope.jsons = json.data;
                     }else{
                         $scope.jsons = $scope.jsons.concat(json.data);
                     }
                     if(json.currentPage == json.totalPage){
                         $scope.page = false;
                     }else{
                         $scope.page ++;
                     }
                 }else{
                     console.log(0)
                     $scope.content = 'none';
                     $scope.contentTxt = json.errmsg;
                 }
                 isLock = true;
             })
     }

     $scope.postLists();
 }]);*/